//
//  UITableViewCell+HDSelectCell.m
//  app
//
//  Created by D on 15/8/24.
//  Copyright (c) 2015年 hdaren. All rights reserved.
//

#import "HDSelectCell.h"

@interface HDSelectCell ()

@property (nonatomic,assign) CGFloat titleWihtd;
@property (nonatomic,strong) HDSelectModel * model_se;
@property (nonatomic,strong) HDBulidingModel * model_bu;
@property (nonatomic,strong) HDHouseModel * model_ho;

@end

@implementation HDSelectCell

-(void)cellWithModel:(id)model Row:(NSInteger)row Sign:(NSString*)sign
{

    if (sign.integerValue == 0) {
        self.model_se = model;
         self.titleWihtd = [XCommon widthForString:self.model_se.community_name fontSize:16];
        
    }else if (sign.integerValue == 1){
        self.model_se = model;
         self.titleWihtd = [XCommon widthForString:self.model_se.group_name fontSize:16];
    }else if (sign.integerValue == 2){
        self.model_bu = model;
        self.titleWihtd = [XCommon widthForString:self.model_bu.building_name fontSize:16];
    }else if (sign.integerValue == 3){
        self.model_ho = model;
        self.titleWihtd = [XCommon widthForString:self.model_ho.house_name fontSize:16];
    }

    UILabel * titleLab = [[UILabel alloc]initWithFrame:CGRectOf([self.ubo fx:0 ox:12 fy:UB_1_2 oy:-16], [self.ubo ow:self.titleWihtd oh:30])];
    
    if (sign.integerValue == 0) {
        
         titleLab.text = self.model_se.community_name;
        
    }else if (sign.integerValue == 1){
         titleLab.text = self.model_se.group_name;
    }else if (sign.integerValue == 2){
        titleLab.text = self.model_bu.building_name;
    }else if (sign.integerValue == 3){
        titleLab.text = self.model_ho.house_name;
    }
    
    [titleLab setFont:[UIFont systemFontOfSize:15]];
    [titleLab setTextColor:[XCommon hexStringToColor:kColor_gray_text]];
    [self addSubview:titleLab];
    
    if (row == [[[NSUserDefaults standardUserDefaults]objectForKey:@"checkRow"]integerValue]) {
        [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"checkRow"];
        
        UIImageView * imageview = [[UIImageView alloc]initWithFrame:CGRectOf([self.ubo ox:SCREEN_WIDTH-32 fy:UB_1_2 oy:-10], [self.ubo ow:20 oh:20])];
        imageview.image = [UIImage imageNamed:@"right"];
        [self addSubview:imageview];
    }
    
}


@end
